<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/html" xmlns:th="http://www.w3.org/1999/xhtml">
<head data-th-replace="seller/sellercommon/sellerhead"></head>
<body>
<!-- this is the common top begin -->
<top data-th-replace="seller/sellercommon/top"></top>

<!-- this is the common top end -->

<div class="container-fluid min-height">
    <lfet data-th-replace="seller/sellercommon/left"></lfet>
    <div class="col-xs-7 border-one border-radius mt-40 ml-30 mb-10">
        <div class="mt-20">
            <a href="#">卖家中心</a>
            <span>&gt;</span>
            <a href="#">商品管理</a>
            <span>&gt;</span>
            <span>管理库存</span>
            <hr/>
        </div>
        <div class="mt-20 ml-80">
            <!-- Modal modify begin-->
            <div class="modal fade bs-example-modal-sm text-center" id="myModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
                <div class="modal-dialog modal-sm " role="document">
                    <div class="modal-content ">
                        <div class="modal-header ">
                            <button type="button" class="close " data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

                        </div>
                        <form action="/seller/updateproduct/" method="post">
                            <input type="hidden" id="id" name="id"/>
                            <div class="modal-body ">
                                <span class="modal-title ">库存数量:</span>
                                <input type="text" name="inventory" class="border-3 ml-5"/><br/>
                                <span class="modal-title mt-20" id="myModalLabel">修改价格:</span>
                                <input type="text" name="price" value="" class="border-3 ml-5 mt-20"/>
                            </div>
                            <div class="modal-footer ">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary">保存修改</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <!--modify end-->

            <!-- seckill begin-->
            <div class="modal fade bs-example-modal-sm text-center" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
                <div class="modal-dialog modal-sm " role="document">
                    <div class="modal-content " style="width: 350px">
                        <div class="modal-header ">
                            <button type="button" class="close " data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

                        </div>
                        <form action="/seckill/doadd/" method="post">
                            <input type="hidden" id="id2" name="id"/>
                            <div class="modal-body">
                                <span class="modal-title mt-20">赠送数量:</span>
                                <input type="text" name="number" value="" class="border-3 ml-5 mt-20" style="width: 190px"/><br/>
                                <span class="modal-title mt-20">抢购时间:</span>
                                <input id="datetimepicker" name="startTime" value="" class="border-3 ml-5 mt-20" style="width: 190px"/>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary">保存修改</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <!--seckill end-->

            <table class="table table-striped">
                <tr th:each="product : ${products}">
                    <td>
                        <img class="sold-pro-img mb-5 mt-20 mr-50" th:src="'/picture/'+${product.pictureId}" src="#" alt="商品1"/>
                        <div class="mt-20" style="display:inline">
                            <span class="mt-20">库存数量：<span th:text="${product.inventory}">00</span></span>
                            <!-- Button trigger modal -->
                            <input type="button" value="修改" class="btn btn-primary mr-50 ml-20" data-toggle="modal" th:onclick="@{'changeInfo('+${product.id}+')'}" data-target="#myModal"/>
                            <input type="button" value="下架商品" class="btn btn-primary mr-50" th:if="${product.isShelf}" th:onclick="@{'this.disabled=this.disabled?false:true;if(disabled) jump('+${product.id}+')'}"/>
                            <input type="button" value="上架商品" class="btn btn-primary mr-50" th:if="!${product.isShelf}" th:onclick="@{'this.disabled=this.disabled?false:true;if(disabled) jump1('+${product.id}+')'}"/>
                            <input type="button" value="发布达米送" class="btn btn-primary mr-50 ml-20" data-toggle="modal" th:onclick="@{'changeInfo('+${product.id}+')'}" data-target="#myModal2"/>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
        <!--page begin-->
        <div class="row">
            <div class="col-lg-2"></div>
            <div class="col-lg-10">
                <!--page begin-->
                <nav data-th-replace="common/pager"></nav>
                <!--page end -->
            </div>
        </div>
        <!--page end -->
    </div>
    <div class="col-xs-1"></div>
</div>


<!--This is the common footer Begin-->
<bottom data-th-replace="seller/sellercommon/bottom"></bottom>


<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="/js/common/jquery-3.1.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/js/bootstrap-datetimepicker.min.js"></script>
<script src="/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script>
    $(document).ready(function(){
        $('#myModal').on('shown.bs.modal', function () {
            $('#myInput').focus()
        })
    });
    function jump(productId){
        location.href = "/seller/unshelfproduct/"+productId;
    }
    function jump1(productId){
        location.href = "/seller/shelfproduct/"+productId;
    }
    function changeInfo(productId){
        $("#id").val(productId);
        $("#id2").val(productId);
    }
    $('#datetimepicker').datetimepicker({
        format: 'yyyy-mm-dd hh:ii'
    });
</script>

</body>
</html>